﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:myNS="clr-namespace:StocksApplicationSL"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" x:Class="StocksApplicationSL.MainPage"
    mc:Ignorable="d"
	Width="640" Height="480">

    <Grid d:DataContext="{d:DesignData /SampleData/MainViewModelSampleData.xaml}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>

        <StackPanel HorizontalAlignment="Left" Margin="0,46,0,-46">
            <StackPanel HorizontalAlignment="Left" Margin="0" VerticalAlignment="Top" Orientation="Horizontal">
                <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Width="186">
                    <TextBlock TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top"><Run Text="From"/><Run Text=":"/></TextBlock>
                    <sdk:Calendar x:Name="FromDate" Margin="0,0,-79,0" d:LayoutOverrides="Width" HorizontalAlignment="Left" VerticalAlignment="Top" HorizontalContentAlignment="Left" SelectedDate="{Binding FromDate, Mode=TwoWay}"/>
                </StackPanel>
                <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Width="186">
                    <TextBlock TextWrapping="Wrap"><Run Text="To"/><Run Text=":"/></TextBlock>
                    <sdk:Calendar x:Name="ToDate" Margin="0,0,-79,0" d:LayoutOverrides="Width" HorizontalAlignment="Left" VerticalAlignment="Top" HorizontalContentAlignment="Left" VerticalContentAlignment="Top" SelectedDate="{Binding ToDate, Mode=TwoWay}"/>
                </StackPanel>
                <StackPanel Height="100" Width="100" HorizontalAlignment="Left" VerticalAlignment="Top">
                    <TextBlock TextWrapping="Wrap"><Run Text="Symbol"/><Run Text=":"/></TextBlock>
                    <TextBox x:Name="Symbol" TextWrapping="Wrap" Text="{Binding Symbol, Mode=TwoWay}"/>
                    <Button x:Name="Haku" Content="Get">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click" SourceName="Haku">
                                <ei:ChangePropertyAction TargetName="Tulokset" PropertyName="Visibility">
                                    <ei:ChangePropertyAction.Ease>
                                        <CubicEase EasingMode="EaseIn"/>
                                    </ei:ChangePropertyAction.Ease>
                                </ei:ChangePropertyAction>
                            </i:EventTrigger>
                            <i:EventTrigger EventName="Click">
                                <ei:CallMethodAction MethodName="UpdateData" TargetObject="{Binding}"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                </StackPanel>
            </StackPanel>
            <StackPanel x:Name="Tulokset" HorizontalAlignment="Left" VerticalAlignment="Top">
                <i:Interaction.Triggers>
                    <i:EventTrigger>
                        <ei:ChangePropertyAction PropertyName="Visibility">
                            <ei:ChangePropertyAction.Value>
                                <Visibility>Collapsed</Visibility>
                            </ei:ChangePropertyAction.Value>
                        </ei:ChangePropertyAction>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
                <sdk:DataGrid x:Name="Lista" 
					ItemsSource="{Binding Rates}" Height="208" Width="466" HorizontalAlignment="Left" VerticalAlignment="Top" AutoGenerateColumns="False">
                    <sdk:DataGrid.Columns>
                        <sdk:DataGridTextColumn Header="Date" Binding="{Binding Date, StringFormat='dd.MM.yyyy'}"/>
                        <sdk:DataGridTextColumn Header="Rate" Binding="{Binding Rate, StringFormat='c'}"/>
                    </sdk:DataGrid.Columns>
                </sdk:DataGrid>
                <StackPanel Orientation="Horizontal">
                    <TextBlock TextWrapping="Wrap" Text="Max date and value:" Margin="0" d:LayoutOverrides="Width" HorizontalAlignment="Left" VerticalAlignment="Top"/>
                    <TextBlock x:Name="MaxDate" TextWrapping="Wrap" Text="{Binding MaxDate, Mode=OneWay, StringFormat='dd.MM.yyyy'}" Margin="0" d:LayoutOverrides="Width" HorizontalAlignment="Left" VerticalAlignment="Top"/>
                    <TextBlock TextWrapping="Wrap" Text=": " Margin="0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
                    <TextBlock x:Name="MaxValue" TextWrapping="Wrap" Text="{Binding MaxValue, Mode=OneWay, StringFormat='c'}" Margin="0" d:LayoutOverrides="Width" VerticalAlignment="Top" HorizontalAlignment="Left"/>
                    <TextBlock TextWrapping="Wrap" Text=" Average value: " Margin="0" d:LayoutOverrides="Width" HorizontalAlignment="Left" VerticalAlignment="Top"/>
                    <TextBlock x:Name="AvgClose" TextWrapping="Wrap" Text="{Binding AvgClose, Mode=OneWay, StringFormat='c'}" Margin="0" d:LayoutOverrides="Width" HorizontalAlignment="Left" VerticalAlignment="Top"/>
                </StackPanel>
            </StackPanel>
        </StackPanel>
    </Grid>
</UserControl>